insert
    overwrite
    table jms_dm.dm_mng_customer_daliy_waybill_taking_detail_dt
    partition
    (dt)
select project_name
     , id
     , code
     , name
     , network_id
     , waybill_no
     , order_status_code
     , input_time
     , pick_time
     , real_pick_network_code
     , dispatch_network_code
     , destination_id
     , cancel_flag
     , pick_flag
     , input_time_6hour as date_time
     , is_sign
     , last_update_time
     , way_input_time
     , sign_falg
     , 7d_update_flag
     , actual_taking_join
     , del_war_flag
     , del_war_join
     , intercept_flag
     , intercept_join
     , difficult_flag
     , difficute_join
     , work_order_flag
     , work_order_join
     , arbitration_flag
     , arbitration_join
     , express_flag
     , express_join
     , xujia_sign_flag
     , xujia_sign_join
     , cancel_time
     , order_id
     , real_pick_network_name
     , sign_network_code
     , sign_network_name
     , sign_time
     , problem_type_id
     , problem_type_code
     , problem_type_name
     , problem_type_subject_id
     , problem_type_subject_code
     , problem_type_subject_name
     , problem_description
     , first_type_code
     , first_type_name
     , second_type_code
     , second_type_name
     , dispatch_time
     , diff_3input_time_flag
     , diff_10input_time_flag
     , wph_pro_name_flag
     , pick_time_flag
     , sender_province_id
     , sender_province_name
     , sender_city_id
     , sender_city_name
     , sender_area_id
     , sender_area_name
     , receiver_province_id
     , receiver_province_name
     , receiver_city_id
     , receiver_city_name
     , receiver_area_id
     , receiver_area_name
     , in_store_scan_time
     , start_time
     , end_time
     , diff_day
     , pp_city_t_timely
     , pc_city_t_timely
     , cp_city_t_timely
     , cc_city_t_timely
     , need_city_t_timely
     , dispatch_network_name
     , taking_early_scantime
     , taking_early_scanday
     , on_taking_flag
     , mall_id
     , mall_name
     , customer_network_id
     , customer_network_code
     , customer_network_name
     , arb_first_type_code
     , arb_first_type
     , arb_second_type_code
     , arb_second_type
     , customer_agent_code
     , customer_agent_name
     , comp_create_time    --客诉登记时间
     , arb_create_time     --仲裁申报时间
     , problem_create_time --质量申报时间
     , input_time_6hour    --订单录入加6日期
     , input_time_6hour as dt
from jms_dm.dm_mng_customer_daliy_waybill_detail_dt
where dt >= date_add('{{ execution_date | cst_ds }}', -45)
  and dt <= '{{ execution_date | cst_ds }}'
  and input_time_6hour >= date_add('{{ execution_date | cst_ds }}', -44)
  and input_time_6hour <= '{{ execution_date | cst_ds }}'
  and actual_taking_join = 1
    distribute by dt
    , pmod(hash(rand()), 10)
;
